<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../../include/admincontent.jsp" %>
<%--<link rel="stylesheet" href="../../../resources/js/plugins/layui/css/layui.css" />--%>
<%--<script src="../../../resources/js/plugins/layui/layui.all.js" type="text/javascript"></script>--%>
<style>
    .searchform{
        line-height: 30px;
        background: #EEF1F8;
        padding: 3px 10px;
        margin: 0px;
        font-size: 12px;
        color: #666;
        text-align: left;
    }

</style>
<div id="location">当前位置：招聘实施管理 > 驾驶员招聘</div>
<div id="Content">

    <!-- 筛选条件 -->
    <form class="layui-form" action="">
        <div id="searchbox" >
            <div class="layui-form-item searchform">
                <div class="layui-inline">
                    <label class="layui-form-label">招聘方案：</label>
                    <div class="layui-input-inline">
                        <select name="pid" lay-search="" lay-filter="projects">${projects}</select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">责任部门：</label>
                    <div class="layui-input-inline">
                        <select name="deptcode" lay-search="" lay-filter="deptcode"></select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button id="flows_searchbtn" class="layui-btn"  type="button"><em class="ico16 search_16"></em>搜索</button>
                </div>
            </div>

            <!--
        <table class="treeTable searchform">
            <thead>
            <tr>
                <td width="60">招聘方案：</td>
                <td width="200">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <select name="pid" lay-search="">${projects}</select>
                            </div>
                        </div>
                    </div>
                </td>
                <td width="60">责任部门：</td>
                <td width="200">
                    <div class="layui-form-item">

                        <select name="deptcode" lay-search></select>
                    </div>
                </td>
                <td width="40">

                </td>
                <td></td>
            </tr>
            </thead>
        </table>-->
        </div>
    </form>

    <div>
        <div class="layui-tab layui-tab-brief" lay-filter="flows">
            <ul class="layui-tab-title">
                <%--<li class="layui-this" lay-id="91d86986-bd4d-4d1c-b5e9-25717fd5e468" lay-url="/Do/DriverResume/">简历筛选</li>
                <li lay-id="681ff23d-2d8b-49c4-b8d9-ef61a7baa72d" lay-url="/Do/DriverExam/" >笔试</li>
                <li lay-id="a89d60fc-c701-4d82-810c-62741322def4" lay-url="/Do/DriverInterview/">面试</li>f
                <li lay-id="c10d2325-8716-476b-a2ee-9f5e3960dd6d" lay-url="/Do/DriverCheck/">资料审核</li>
                <li lay-id="55f6596b-cdd2-405a-a1e5-cd6e4af1cd7b" lay-url="/Do/DriverOperation/">实作</li>
                <li lay-id="95976018-e77e-4c8b-97b6-08b7f7905201" lay-url="/Do/DriverPhysical/">体检</li>
                <li lay-id="215e7f21-189b-45af-adc0-ddfd2f4c2553" lay-url="/Do/DriverPReview/" class="layui-disabled">背景调查</li>
                <li lay-id="852483fb-1ae5-469c-9689-b3b5aa8adde7" lay-url="/Do/DriverEmploy/">录用</li>--%>
            </ul>
            <div class="layui-tab-content" >
                <%--<div class="layui-tab-item"  >
                    <iframe id="tab_iframe"  style="min-height: 500px;" width="100%" height="100%"  frameborder="0" ></iframe>
                </div>--%>
                <%--<div class="layui-tab-item layui-show">

                    <div id="jlsx"></div>
                    <script>
                        $(function () {
                            var layid = $('.layui-tab .layui-tab-title .layui-this').attr('lay-id');
                            var url=$('.layui-tab .layui-tab-title .layui-this').attr('lay-url');
                            $.ajax({
                                url:'/Do/DriverResume/',
                                data:{pid:$('select[name=pid]').val(),
                                    fid:layid,
                                    deptcode:$('select[name=deptcode]').val()},
                                dataType:'html',
                                success:function (_html) {
                                    $("#jlsx").append(_html);
                                   /* // 第一步：匹配加载的页面中是否含有js
                                    var regDetectJs = /<script(.|\n)*?>(.|\n|\r\n)*?<\/script>/ig;
                                    var jsContained = _html.match(regDetectJs);

                                    // 第二步：如果包含js，则一段一段的取出js再加载执行
                                    if(jsContained) {
                                        // 分段取出js正则
                                        var regGetJS = /<script(.|\n)*?>((.|\n|\r\n)*)?<\/script>/im;

                                        // 按顺序分段执行js
                                        var jsNums = jsContained.length;
                                        for (var i=0; i<jsNums; i++) {
                                            var jsSection = jsContained[i].match(regGetJS);

                                            if(jsSection[2]) {
                                                if(window.execScript) {
                                                    // 给IE的特殊待遇
                                                    window.execScript(jsSection[2]);
                                                } else {
                                                    // 给其他大部分浏览器用的
                                                    window.eval(jsSection[2]);
                                                }
                                            }
                                        }
                                    }*/

                                }
                            })
                        })

                    </script>
                    <!--
                    <iframe src="/Do/DriverResume/?pid=A_971982c7-1de0-4b56-8fb8-904cb251ecd7&fid=91d86986-bd4d-4d1c-b5e9-25717fd5e468&deptcode=00006" width="100%" height="100%" frameborder="0" style="overflow: hidden" ></iframe>
                    -->
                </div>
                <div class="layui-tab-item">

                    内容2
                </div>
                <div class="layui-tab-item">内容3</div>
                <div class="layui-tab-item">内容4</div>
                <div class="layui-tab-item">内容5</div>--%>


            </div>

        </div>

    </div>

    <!--
    <div class="tabbar">
        <a href="/Do/DriverResume/?pid=A_971982c7-1de0-4b56-8fb8-904cb251ecd7&fid=91d86986-bd4d-4d1c-b5e9-25717fd5e468&deptcode=00006" class="current">简历筛选</a>
        <a href="/Do/MS/gx">笔试</a>
        <a href="/Do/MS/gx">面试</a>
        <a href="/Do/MS/nz">资料审核</a>
        <a href="/Do/MS/nz">实作</a>
        <a href="/Do/MS/nz">体检</a>
        <a href="/Do/MS/nz">背景调查</a>
        <a href="/Do/MS/nz">录用</a>
    </div>-->



</div>
<script type="text/javascript">
    var nowflows='';
    var allflows=[];
    var element;
    var form ;
    layui.use(['form','util'], function(){
        form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.on('select(projects)', function(data){
            getAjax('${path}/Do/Driver/getdept?pid=' + data.value, null, function (data) {
                $("select[name=deptcode]").html(data);

                form.render();
            });
        });
        //……
        //但是，如果你的HTML是动态生成的，自动渲染就会失效
        //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
        form.render();
        var util = layui.util;
        //固定块
        util.fixbar({
            top: true
            , css: {right: 10, bottom: 10}
            , bgcolor: '#393D49'
        });
    });

    layui.use('element', function() {
        var $ = layui.jquery;
        element = layui.element;

        //Hash地址的定位
        /* var layid = location.hash.replace(/^#fid=/, '');
         element.tabChange('flows', layid);*/

        element.on('tab(flows)', function(elem){
            /* location.hash = 'fid='+ $(this).attr('lay-id');*/
            /*var url=$('.layui-tab .layui-tab-title .layui-this').attr('lay-url');
             var fid=$('.layui-tab .layui-tab-title .layui-this').attr('lay-id');
             var pid=$('select[name=pid]').val();
             var deptcode=$('select[name=deptcode]').val();
            console.log(this); //当前Tab标题所在的原始DOM元素
             console.log(elem.index); //得到当前Tab的所在下标
             console.log(elem.elem); //得到当前的Tab大容器*/
            var clickIndex=elem.index;
            var iframeurl=$(this).attr('lay-url');
            var fid=$(this).attr('lay-id');
            if($(this).hasClass("layui-disabled")){
                layer.msg('尚未进入到该流程!',{icon:2,time:2000},function () {
                    if(clickIndex!=0){
                        element.tabChange('flows', nowflows);
                    }
                });
                return false;
            }else{
                // iframeurl+="?pid=" + $('select[name=pid]').val() + "&fid="+fid+"&deptcode=" + $('select[name=deptcode]').val();
                $(".layui-tab-content").empty();
                $(".layui-tab-content").append(
                    '<div class="layui-tab-item layui-show" >' +
                    '<iframe id="mainiframe" src="'+iframeurl+'?pid=' + $('select[name=pid]').val() + '&fid='+fid+'&deptcode=' + $('select[name=deptcode]').val()+'"  width="100%" height="100%"  frameborder="0" onload="changeFrameHeight()"></iframe>'+
                    '</div>');

            }
            /*$.ajax({
                url:url,
                data:{pid:pid,
                    fid:fid,
                    deptcode:deptcode},
                dataType:'html',
                success:function (_html) {
                    $('#tabItme_'+fid).empty();
                    $('#tabItme_'+fid).append(_html);
                }
            })*/
        });

    });

    $(document).ready(function () {
        //getdept();

        $('#flows_searchbtn').click(function () {
            getFlowsList();
        });


    });

    function getFlowsList() {
        /* getAjax('${path}/Do/Driver/getflows?pid=' + $('select[name=pid]').val() + '&deptcode=' + $('select[name=deptcode]').val(), null, function (data) {
            $("#result").html(data);
        },"JSON");*/
        loadTab();
    }

    function loadTab(fid) {
        var tabJson=null;
        $.get('${path}/Do/Driver/getFlowsJson?pid=' + $('select[name=pid]').val() + '&deptcode=' + $('select[name=deptcode]').val(), null, function (data) {
            if(data.length>0){
                allflows.length=0;
                $('.layui-tab .layui-tab-title').empty();
                $(data).each(function (index,obj) {
                    allflows.push(obj.fid);
                    if(obj.state==0){
                        $('.layui-tab .layui-tab-title').append('<li class="layui-disabled" lay-id="'+obj.fid+'" lay-url="'+obj.url+'" >'+obj.txt+'</li>');
                    }else{
                        nowflows=obj.fid;
                        $('.layui-tab .layui-tab-title').append('<li  lay-id="'+obj.fid+'" lay-url="'+obj.url+'" >'+obj.txt+'</li>');
                    }

                    //新增一个Tab项
                    /* element.tabAdd('flows', {
                         title: obj.txt //用于演示
                         ,content: '内容'+ (Math.random()*1000|0)
                         ,id: obj.fid //实际使用一般是规定好的id，这里以时间戳模拟下
                         ,shin:'layui-disabled'
                     })*/
                    /*  $(".layui-tab-content ").append(
                           '<div class="layui-tab-item " >' +
                           '<iframe id="iframe_'+obj.fid+'" src="'+obj.url+'?pid=' + $('select[name=pid]').val() + '&fid='+obj.fid+'&deptcode=' + $('select[name=deptcode]').val()+'" style="min-height: 500px;" width="100%" height="100%"  frameborder="0" onload="setIframeHeight(this)"></iframe>'+
                           '</div>');*/
                    // $('.layui-tab-content').append();
                });

                element.tabChange('flows', nowflows);
                element.render();
            }
        },"JSON");
    }

    function changeFrameHeight(){
        setTimeout(function () {
            var ifm= document.getElementById("mainiframe");
            var cheight=document.documentElement.clientHeight;
            var oheight=document.documentElement.offsetHeight;
            var sheight=ifm.contentWindow.document.documentElement.offsetHeight;
            var soheight=ifm.contentWindow.document.documentElement.clientHeight;
            /*if(sheight<=cheight){
                ifm.height=cheight;
            }else{
                ifm.height=sheight+oheight+10;
            }*/
            //ifm.height=cheight-soheight+10;
            //console.log("ifmHeight:"+ifm.height);
            ifm.height=sheight+150;
        },500)
    }
    /*function setIframeHeight(iframe) {
        if (iframe) {
            var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
            if (iframeWin.document.body) {
                iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
            }
        }
    };*/


</script>
</body>
</html>